home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Medal Software 3
/
Gold Medal Software - Volume 3 (Gold Medal) (1994).iso
/
prog
/
proxy14.arj
/
SORT.PRX
< prev
next >
Wrap
Text File
|
1994-03-03
|
533b
|
17 lines
eos="eos";
ch1=channel();
ch2=channel();
task sort(inp,out;x,y,succ) {
inp?x;if (x==eos) {out!x;skip;}
succ=channel(); start sort(succ,out);
while (true)
{inp?y;if(y==eos) {out!x;succ!y;skip;}
if(x>y) {succ!x;x=y;} else succ!y;
} };
task source(out) {
out!5;out!1;out!2;out!4;out!3;out!7;out!8;out!6;out!eos;};
task sink(inp;x) {
inp?x;while(x!=eos) {print x;inp?x;}};
task main() {start source(ch1);start sort(ch1,ch2);start sink(ch2);};
end